package start.spring.basic.flowable.controller.applyrecord;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import start.spring.basic.flowable.common.SysConstant;
import start.spring.basic.flowable.controller.BaseController;
import start.spring.basic.flowable.entity.WfApplyRecord;
import start.spring.basic.flowable.service.applyrecord.IWfApplyRecordService;
import start.spring.basic.log.ServiceLog;
import start.spring.basic.page.PageQuery;
import start.spring.basic.response.ResponseData;
import start.spring.basic.response.ResponsePage;

/**
 * 
 * @author csc
 * @date 2023-12-09
 *
 */
@RestController
@RequestMapping("/applyrecord")
@Api(tags = "我的流程相关接口")
public class WfApplyRecordController extends BaseController {
	
    @Autowired
    private IWfApplyRecordService wfApplyRecordService;
	
    @ServiceLog(businessType = "查询我的流程列表", systemType = SysConstant.SYSTEM_TYPE, recordResult = false, userId = "")
    @RequiresPermissions("workflow:applyrecord:list")
    @PostMapping("/list")
    @ApiOperation(value = "查询我的流程列表", notes = "分页查询")
    public ResponsePage<WfApplyRecord> list(PageQuery pageQuery, @RequestBody WfApplyRecord wfApplyRecord) {
    	return super.returnResponse(this.wfApplyRecordService.selectWfApplyRecordPageList(pageQuery, wfApplyRecord));
    }
	
    @ServiceLog(businessType = "删除我的流程", systemType = SysConstant.SYSTEM_TYPE, recordResult = true, userId = "")
    @RequiresPermissions("workflow:applyrecord:list")
    @PostMapping("/remove")
    @ApiOperation(value = "删除我的流程", notes = "")
    public ResponseData<String> remove(@RequestBody List<String> ids) {
    	return this.wfApplyRecordService.deleteWfApplyRecordByIds(ids);
    }
    
    @ServiceLog(businessType = "撤回申请记录", systemType = SysConstant.SYSTEM_TYPE, recordResult = true, userId = "")
    @RequiresPermissions("workflow:applyrecord:list")
    @GetMapping("/revoke/{id}")
    @ApiOperation(value = "撤回申请记录", notes = "")
    public ResponseData<String> revoke(@PathVariable String id) {
    	return this.wfApplyRecordService.revokeWfApplyRecordById(id);
    }
    
}
